/**
 *====================================================
 * 文件名称: DetainedInventoryServiceImpl.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年09月23日	chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.DetainedInventoryEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;

/**
 * @ClassName: DetainedInventoryServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年09月23日 18:56:17
 */
@Implements(DetainedInventoryService.class)
public class DetainedInventoryServiceImpl implements DetainedInventoryService {

	@Override
	public Long createDetainedInventory(DetainedInventoryEntity entity) {
		PersistUtil.insert(entity);
		return entity.getDetainedInventoryId();
	}

	@Override
	public void deleteDetainedInventory(Long detainedInventoryId) {
		PersistUtil.delete(DetainedInventoryEntity.class, detainedInventoryId);
	}

	@Override
	public List<DetainedInventoryEntity> inquireDetainedInventoryList(Long detainedId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(DetainedInventoryEntity.class);
		criteria.add(Restrictions.eq("detainedId", detainedId));
		return PersistUtil.get(criteria);
	}

	@Override
	public List<Long> inquireGroupDetainedInventoryIds(Long detainedId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(DetainedInventoryEntity.class);
		criteria.add(Restrictions.eq("detainedId", detainedId));
		criteria.setProjection(Projections.property("inventoryId"));
		return PersistUtil.get(criteria);
	}

}
